<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>订单管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			
		});
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
        	return false;
        }
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li class="active"><a href="${ctx}/ems/emsOrder/">订单列表</a></li>
		<shiro:hasPermission name="ems:emsOrder:edit"><li><a href="${ctx}/ems/emsOrder/form">订单添加</a></li></shiro:hasPermission>
	</ul>
	<form:form id="searchForm" modelAttribute="emsOrder" action="${ctx}/ems/emsOrder/" method="post" class="breadcrumb form-search">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		<ul class="ul-form">
			<li><label>订单编号：</label>
				<form:input path="orderNo" htmlEscape="false" maxlength="64" class="input-medium"/>
			</li>
			<li><label>状态：</label>
				<form:select path="status" class="input-medium">
					<form:option value="" label=""/>
					<form:options items="${fns:getDictList('ems_order_status')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
				</form:select>
			</li>
			<li class="btns"><input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/></li>
			<c:if test="${not empty message }">
				<li><font style="margin-left: 100px;line-height: 50px;font-size: 20px;color: red;">${message }</font></li>
			</c:if>
			<li class="clearfix"></li>
		</ul>
	</form:form>
	<sys:message content="${message}"/>
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead>
			<tr>
				<th>订单编号</th>
				<th>订单名称</th>
				<th>支付方式</th>
				<th>订单类型</th>
				<th>报名人数</th>
				<th>报名人次</th>
				<th>实际金额</th>
				<th>应付金额</th>
				<th>创建时间</th>
				<th>接口返回时间</th>
				<th>状态</th>
				<th>备注</th>
				<shiro:hasAnyPermissions name="ems:emsOrder:view,ems:emsOrderRefund:edit"><th>操作</th></shiro:hasAnyPermissions>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${page.list}" var="emsOrder">
			<tr>
				<td><a href="${ctx}/ems/emsOrder/form?id=${emsOrder.id}">
					${emsOrder.orderNo}
				</a></td>
				<td>
					${emsOrder.name}
				</td>
				<td>
					${'wechatpay' eq emsOrder.payType ? '微信支付':'alipay' eq emsOrder.payType ? '支付宝':'pos支付'}
				</td>
				<td>
					${'1' eq emsOrder.type?'后台订单':'前台订单'}
				</td>
				<td>
					${emsOrder.personNum}
				</td>
				<td>
					${emsOrder.personTime}
				</td>
				<td>
					${emsOrder.sumMoney}
				</td>
				<td>
					${emsOrder.payMoney}
				</td>
				<td>
					<fmt:formatDate value="${emsOrder.createDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
				</td>
				<td>
					<fmt:formatDate value="${emsOrder.successDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
				</td>
				<td>
					${fns:getDictLabel(emsOrder.status, 'ems_order_status', '')}
				</td>
				<td>
					${emsOrder.remarks}
				</td>
				<td>
					<shiro:hasPermission name="ems:emsOrder:view">
    					<a href="${ctx}/ems/emsOrder/form?id=${emsOrder.id}">修改</a>
    				</shiro:hasPermission>
					<shiro:hasPermission name="ems:emsOrderRefund:edit">
						<!-- 后台订单（现场报名由报名管理员生成的订单，现场缴费） -->
						<c:if test="${emsOrder.type eq '1'}">
							<!-- 当订单已经支付并且没有退单记录时，才可以退单 -->
							<c:if test="${emsOrder.refundCount lt '1' and emsOrder.status eq '1'}">
	    						<a href="${ctx}/ems/emsOrderRefund/createRefundOrder?orderId=${emsOrder.id}" onclick="return confirmx('确认要退款吗？请确认线下给用户退费${emsOrder.payMoney}元。', this.href)">退款</a>
	    					</c:if>
    					</c:if>
    					<!-- 前台订单（由报名人注册后通过网上报名系统报名生成，线上支付） -->
						<%-- <c:if test="${emsOrder.type eq '0'}">
							<!-- 当该订单有退款申请时，才可以退单 -->
							<c:if test="${emsOrder.refundCount lt '1' and emsOrder.status eq '1'}">
	    						<a href="${ctx}/ems/emsOrderRefund/createRefundOrder?orderId=${emsOrder.id}" onclick="return confirmx('确认要退款吗？请确认线下给用户退费${emsOrder.payMoney}元。', this.href)">退款</a>
	    					</c:if>
    					</c:if> --%>
    				</shiro:hasPermission>
				</td>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
</body>
</html>